import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { NzModalService } from 'ng-zorro-antd';

@Component({
  selector: 'app-main',
  templateUrl: './main.component.html',
  styleUrls: ['./main.component.less']
})
export class MainComponent implements OnInit {

  userName: string = '';
  isCollapsed: boolean = false;
  menus: any[] = [
    { type: 'menu-item', name: '总览', link: '/main/index', icon: 'appstore', },
    { type: 'menu-item', name: '直播间', link: '/main/live', icon: 'camera' },
    { type: 'menu-item', name: '点播视频库', link: '/main/vod', icon: 'video-camera' },
    { type: 'menu-item', name: '汇集平台', link: '/main/collect-platform', icon: 'desktop' },
    { type: 'menu-item', name: '页面编辑器', link: '/main/page-editor', icon: 'edit' },
    { type: 'menu-item', name: '账户', link: '/main/account', icon: 'transaction' },
    { type: 'menu-item', name: '工单', link: '/main/work', icon: 'tool' },
    { type: 'menu-item', name: '安全配置', link: '/main/user', icon: 'user' }
  ]

  toggleCollapsed(): void {
    this.isCollapsed = !this.isCollapsed;
  }

  loginOut() {
    this.modalService.confirm({
      nzTitle: '信息提示',
      nzContent: '<b style="color: red;">确定要退出系统吗?</b>',
      nzOkText: '确定',
      nzOkType: 'danger',
      nzOnOk: () => {
        this.router.navigateByUrl('/login');
      },
      nzCancelText: '取消'
    });
  }

  constructor(
    private modalService: NzModalService,
    private router: Router
  ) { }

  ngOnInit(): void {
    this.userName = window.sessionStorage['username'];

  }

}